package com.commpany.servie.basic.product.business.read.product.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.commpany.jdq.core.orm.Pagination;
import com.commpany.servie.basic.product.business.read.product.ProductReadManage;
import com.commpany.servie.basic.product.dao.read.ProductReadDAO;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import com.commpany.jdq.core.common.PageResult;
import com.commpany.jdq.core.common.BaseReadManager;
import com.commpany.servie.basic.product.po.ProductPO;
@Slf4j
@Service
public class ProductReadManageImpl extends BaseReadManager<ProductPO> implements ProductReadManage {
	@Autowired
	private ProductReadDAO productReadDAO;
	
	@Override
    public ProductPO getProductService(ProductPO po){
                 checkParams(po);
         return  productReadDAO.findById(po);
    }
    @Override
	public PageResult<ProductPO> selectProductPageService(ProductPO po, Pagination page){
	       checkParams(po);
	    page.setLimitStart((page.getPageNo()) * page.getPageSize());
		PageResult<ProductPO> result = new PageResult<ProductPO>();
		List<ProductPO> list = productReadDAO.findOfPage(po, page);
		int count = productReadDAO.countOfPage(po);
		result.setList(list);
		result.setTotalSize(count);
		result.copy(page);
		return result;
		
	}
	
    @Override
	public int countProductService( ProductPO po ){
	            checkParams(po);
	    return productReadDAO.countOfPage(po);
	
	}
	
    @Override
	public List<ProductPO> queryProductService(ProductPO po){
	            checkParams(po);
	   return  productReadDAO.findAll(po);
	}
	
}
	